package com.masterclient.app.businessmodule.minemodule.point.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.masterclient.app.App;
import com.masterclient.app.R;
import com.masterclient.app.businessmodule.minemodule.point.model.PointExchange;

/**
 * 作者：sean
 * 创建时间：2017/10/13 17:00
 * 功能说明：
 */

public class PointExchangeAdapter extends BaseQuickAdapter<PointExchange,BaseViewHolder>{
    public PointExchangeAdapter() {
        super(R.layout.point_exchange_item);
    }

    @Override
    protected void convert(BaseViewHolder helper, PointExchange item) {

        ImageView image = helper.getView(R.id.image);


        if(item != null){
            if(!TextUtils.isEmpty(item.getSh_image())){
                App.picasso.load(item.getSh_image())
                        //.resize(ScreenUtils.dp2px(180),ScreenUtils.dp2px(120))
                        .placeholder(R.mipmap.defaults_1)
                        .into(image);
            }
            helper.setText(R.id.title,item.getSh_name());

            String desc = "";
            if (item.getSh_attribute() != null) {
                for (PointExchange.Property temp : item.getSh_attribute()) {
                    desc += temp.getSh_attribute_label() + ":" + temp.getSh_alias_name();
                }
            }
            helper.setText(R.id.sku_desc,desc);


            helper.setText(R.id.point,item.getSh_integral());
            helper.setText(R.id.time,item.getSh_create_at());


        }

    }

}
